package com.xycake.service;


import com.xycake.dao.GoodsMapper;
import com.xycake.dao.ImgMapper;
import com.xycake.entity.Goods;
import com.xycake.entity.Img;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    @Autowired
    private ImgMapper imgMapper;

    public List<Goods> selectGoodsById(Integer id) {
        return goodsMapper.selectGoodsById(id);
    }

    public List<Img> selectImgById(Integer goodsId) {
        return imgMapper.selectImgById(goodsId);
    }

    public Goods selectPriceById(Integer id) {
        return goodsMapper.selectPriceById(id);
    }

    public List<Goods> selectAllGoods() {
        return goodsMapper.selectAllgoods();
    }

    public void delGoodsById(Integer id) {
        goodsMapper.deleteByPrimaryKey(id);
    }

    public void upimgById(Goods goods) {
        goodsMapper.updateByPrimaryKeySelective(goods);
    }

    public void updataGoods(Goods goods) {
        goodsMapper.updateByPrimaryKeySelective(goods);
    }

    public void insertGoods(Goods goods) {
        goodsMapper.insertSelective(goods);
    }
}
